const fs = require("fs");

const rds = fs.createReadStream("./abc.txt", {
  start: 8,
  end: 22,
  highWaterMark: 3,
});

// 读取到数据自动帮助发送一个事件

// 通过流来打开文件
rds.on("data", (data) => {
  console.log(data.toString());
});
rds.on("open", (fd) => {
  console.log(fd);
  //   fs.fstat(fd, (err, files) => {
  //     console.log(files);
  //   });
});

rds.on("end", () => {
  console.log("已经读取到end位置");
});

rds.on("close", () => {
  console.log("文件被关闭");
});
